#include<iostream>
#include<string>
#include<map>
using namespace std;
map<int, int> mp;
std::string s;
int main()
{
    int retmin = 0x3f3f3f3f, retmax = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x; cin >> x;
        mp[x]++;
        retmin = min(retmin, x);
        retmax = max(retmax, x);
    }
    cout << retmin << " " << mp[retmin] << endl << retmax << " " << mp[retmax] << endl;
    return 0;
}